﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Drawing.Drawing2D;

namespace OpenComposite.Workflow
{
	[Designer(typeof(HorizontalCancellationHandlerDesigner))]
	[AlternateFlowActivity()]
	public partial class HorizontalCancellationHandlerActivity : HorizontalSequenceActivity
	{
		public HorizontalCancellationHandlerActivity()
		{

		}
	}

	[ActivityDesignerTheme(typeof(HorizontalCancellationHandlerTheme))]
	public class HorizontalCancellationHandlerDesigner : HorizontalSequenceDesigner
	{

		public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
		{
			if ( parentActivityDesigner is HorizontalCancellationHandlerDesigner ||
				parentActivityDesigner is HorizontalFaultHandlersDesigner ) {
				return false;
			} else {
				return base.CanBeParentedTo(parentActivityDesigner);
			}
		}

		protected override void OnPaint(ActivityDesignerPaintEventArgs e)
		{
			GraphicsPath path = new GraphicsPath();
			path = ActivityDesignerPaint.GetRoundedRectanglePath(Bounds, 10);
			using ( LinearGradientBrush lb = 
				new LinearGradientBrush(Bounds, e.DesignerTheme.BackColorStart, e.DesignerTheme.BackColorEnd, e.DesignerTheme.BackgroundStyle) ) {
				e.Graphics.FillPath(lb, path);
			}
			//e.Graphics.DrawPath(e.DesignerTheme.ForegroundPen, path);
			base.OnPaint(e);
		}
	}

	public class HorizontalCancellationHandlerTheme : CompositeDesignerTheme
	{
		public HorizontalCancellationHandlerTheme(WorkflowTheme theme)
			: base(theme)
		{
			this.BackColorStart = Color.White;
			this.BackColorEnd = Color.YellowGreen;
		}
	}
}